package com.lzq.system.repository;

import com.lzq.system.info.UserInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.lzq.system.entity.UserEntity;

import javax.transaction.Transactional;
import java.util.Collection;
import java.util.Date;
import java.util.List;

@Repository
public interface UserRepository extends JpaRepository<UserInfo,Long> {

    //删除多个用户数据
    //这里的 Collection<Long> 是Java集合框架中的一个接口类型，表示一组 Long 类型对象的集合
    @Modifying
    @Transactional
    @Query("update UserInfo set ustatus = 1 where uid in (?1)")
    public int updates(Collection<Long> ids);


    /**
     * 根据jpa语句查询
     * @param phone
     * @return
     */
    @Query("select ui from UserInfo ui where ui.uphone = ?1")
    public List<UserInfo> findUsers1(String phone);


    /**
     * 根据sql语句查询
     */
    @Query(nativeQuery = true,value = "select * from UserInfo where uaccount = ?1")
    public List<UserInfo> findUsser2(String uaccount);

    public List<UserInfo> findAllByUtimeBetween(Date t1,Date t2);
}
